Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Icon (programming language)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Icon_(programming_language)"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Icon_programming_language rootpage-Icon_programming_language skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Icon (programming language)</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">This article is about the programming language. For pictogram or computer image, see <a href="Icon_(computing)" title="Icon (computing)">Icon (computing)</a>. For Icon-L graphical programming of embedded systems, see <a href="https://de.wikipedia.org/wiki/iCon-L" class="extiw external" title="de:iCon-L">de: iCon-L</a>.</div>
<style data-mw-deduplicate="TemplateStyles:r1295905060">
/* start https://en.wikipedia.org/ */


.mw-parser-output .infobox-subbox{padding:0;border:none;margin:-3px;width:auto;min-width:100%;font-size:100%;clear:none;float:none;background-color:transparent}.mw-parser-output .infobox-3cols-child{margin:auto}.mw-parser-output .infobox .navbar{font-size:100%}@media screen{html.skin-theme-clientpref-night .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media(min-width:640px){body.skin--responsive .mw-parser-output .infobox-table{display:table!important}body.skin--responsive .mw-parser-output .infobox-table>caption{display:table-caption!important}body.skin--responsive .mw-parser-output .infobox-table>tbody{display:table-row-group}body.skin--responsive .mw-parser-output .infobox-table th,body.skin--responsive .mw-parser-output .infobox-table td{padding-left:inherit;padding-right:inherit}}


/* end https://en.wikipedia.org/ */
</style><table class="infobox vevent"><tbody><tr><th colspan="2" class="infobox-above" style="background-color:#e0e0e0;">Icon</th></tr><tr><td colspan="2" class="infobox-image"><span typeof="mw:File"></span></td></tr><tr><th scope="row" class="infobox-label"><a href="Programming_paradigm" title="Programming paradigm">Paradigms</a></th><td class="infobox-data"><a href="Multi-paradigm_programming_language" class="mw-redirect" title="Multi-paradigm programming language">multi-paradigm</a>: <a href="Structured_programming" title="Structured programming">structured</a>, text-oriented</td></tr><tr><th scope="row" class="infobox-label">Family</th><td class="infobox-data"><a href="SNOBOL" title="SNOBOL">SNOBOL</a></td></tr><tr><th scope="row" class="infobox-label"><a href="Software_design" title="Software design">Designed&nbsp;by</a></th><td class="infobox-data"><a href="Ralph_Griswold" title="Ralph Griswold">Ralph Griswold</a></td></tr><tr><th scope="row" class="infobox-label">First&nbsp;appeared</th><td class="infobox-data">1977<span style="display:none">&nbsp;(<span class="bday dtstart published updated">1977</span>)</span></td></tr><tr><td colspan="2" class="infobox-full-data"></td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="Software_release_life_cycle" title="Software release life cycle">Stable release</a></th><td class="infobox-data"><div style="margin:0px;">9.5.24a
/ January&nbsp;17, 2024<span style="display:none">&nbsp;(<span class="bday dtstart published updated">2024-01-17</span>)</span><sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup></div></td></tr><tr style="display:none"><td colspan="2">
</td></tr><tr><th scope="row" class="infobox-label"><a href="Type_system" title="Type system">Typing discipline</a></th><td class="infobox-data"><a href="Dynamic_typing" class="mw-redirect" title="Dynamic typing">dynamic</a></td></tr><tr><th scope="row" class="infobox-label">Website</th><td class="infobox-data"><span class="url"><a rel="nofollow" class="external text" href="http://www.cs.arizona.edu/icon">www<wbr>.cs<wbr>.arizona<wbr>.edu<wbr>/icon</a></span></td></tr><tr><th colspan="2" class="infobox-header" style="background-color: #EEEEEE;">Major <a href="Programming_language_implementation" title="Programming language implementation">implementations</a></th></tr><tr><td colspan="2" class="infobox-full-data">Icon, Jcon</td></tr><tr><th colspan="2" class="infobox-header" style="background-color: #EEEEEE;"><a href="Programming_language#Dialects,_flavors_and_implementations" title="Programming language">Dialects</a></th></tr><tr><td colspan="2" class="infobox-full-data"><a href="Unicon_(programming_language)" title="Unicon (programming language)">Unicon</a></td></tr><tr><th colspan="2" class="infobox-header" style="background-color: #EEEEEE;">Influenced by</th></tr><tr><td colspan="2" class="infobox-full-data"><a href="SNOBOL" title="SNOBOL">SNOBOL</a>, SL5, <a href="ALGOL" title="ALGOL">ALGOL</a></td></tr><tr><th colspan="2" class="infobox-header" style="background-color: #EEEEEE;">Influenced</th></tr><tr><td colspan="2" class="infobox-full-data">Unicon, <a href="Python_(programming_language)" title="Python (programming language)">Python</a>, Goaldi,<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> <a href="Jq_(programming_language)" title="Jq (programming language)">jq</a></td></tr></tbody></table>
<p><b>Icon</b> is a <a href="Very_high-level_programming_language" title="Very high-level programming language">very high-level programming language</a> based on the concept of "goal-directed execution" in which an <a href="Expression_(computer_science)" title="Expression (computer science)">expression</a> in code returns "success" along with a result, or a "failure", indicating that there is no valid result. The success and failure of a given expression is used to direct further processing, whereas conventional languages would typically use <a href="Boolean_logic" class="mw-redirect" title="Boolean logic">Boolean logic</a> written by the programmer to achieve the same ends. Because the logic for basic control structures is often implicit in Icon, common tasks can be completed with less explicit code.
</p><p>Icon was designed by <a href="Ralph_Griswold" title="Ralph Griswold">Ralph Griswold</a> after leaving <a href="Bell_Labs" title="Bell Labs">Bell Labs</a> where he was a major contributor to the <a href="SNOBOL" title="SNOBOL">SNOBOL</a> language. SNOBOL was a string-processing language with what would be considered dated syntax by the standards of the early 1970s. After moving to the <a href="University_of_Arizona" title="University of Arizona">University of Arizona</a>, he further developed the underlying SNOBOL concepts in SL5, but considered the result to be a failure. This led to the significantly updated Icon, which blends the short but conceptually dense code of SNOBOL-like languages with the more familiar syntax of <a href="ALGOL" title="ALGOL">ALGOL</a>-inspired languages like <a href="C_(programming_language)" title="C (programming language)">C</a> or <a href="Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>.
</p><p>Like the languages that inspired it, the primary area of use of Icon is managing <a href="String_(computer_science)" title="String (computer science)">strings</a> and textual patterns. String operations often fail, for instance, finding "the" in "world". In most languages, this requires testing and branching to avoid using a non-valid result. In Icon most of these sorts of tests are simply unneeded, reducing the amount of code that must be written. Complex pattern handling can be done in a few lines of terse code, similar to more dedicated languages like <a href="Perl" title="Perl">Perl</a> but retaining a more function-oriented syntax familiar to users of other ALGOL-like languages.
</p><p>Icon is not <a href="Object-oriented_programming" title="Object-oriented programming">object-oriented</a>, but an object-oriented extension named Idol was developed in 1996 which eventually became <a href="Unicon_(programming_language)" title="Unicon (programming language)">Unicon</a>. It also inspired other languages, with its simple generators being especially influential; Icon's generators were a major inspiration for the <a href="Python_(programming_language)" title="Python (programming language)">Python</a> language.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="History">History</h2></div>
<div class="mw-heading mw-heading3"><h3 id="SNOBOL">SNOBOL</h3></div>
<p>The original <a href="SNOBOL" title="SNOBOL">SNOBOL</a> effort, retroactively known as SNOBOL1, launched in the fall of 1962 at the <a href="Bell_Labs" title="Bell Labs">Bell Labs</a> Programming Research Studies Department.<sup id="cite_ref-FOOTNOTEGriswold1981601,_602_4-0" class="reference"><a href="#cite_note-FOOTNOTEGriswold1981601,_602-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> The effort was a reaction to the frustrations of attempting to use the SCL language for polynomial formula manipulation, symbolic integration and studying <a href="Markov_chain" title="Markov chain">Markov chains</a>. SCL, written by the department head Chester Lee, was both slow and had a low-level syntax that resulting in volumes of code for even simple projects. After briefly considering the COMIT language, Ivan Polonsky, Ralph Griswold and David Farber, all members of the six-person department, decided to write their own language to solve these problems.<sup id="cite_ref-FOOTNOTEGriswold1981602_5-0" class="reference"><a href="#cite_note-FOOTNOTEGriswold1981602-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</p><p>The first versions were running on the <a href="IBM_7090" title="IBM 7090">IBM 7090</a> in early 1963, and by the summer had been built out and was being used across Bell. This led almost immediately to SNOBOL2, which added a number of built-in functions, and the ability to link to external <a href="Assembly_language" title="Assembly language">assembly language</a> code. It was released in April 1964 and mostly used within Bell, but also saw some use at <a href="Project_MAC" class="mw-redirect" title="Project MAC">Project MAC</a>. The introduction of system functions served mostly to indicate the need for user-defined functions, which was the major feature of SNOBOL3, released in July 1964.<sup id="cite_ref-FOOTNOTEGriswold1981606_6-0" class="reference"><a href="#cite_note-FOOTNOTEGriswold1981606-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>
</p><p>SNOBOL3's introduction corresponded with major changes within the Bell Labs computing department, including the addition of the new <a href="GE_645" title="GE 645">GE 645</a> mainframe which would require a rewrite of SNOBOL. Instead, the team suggested writing a new version that would run on a <a href="Virtual_machine" title="Virtual machine">virtual machine</a>, named SIL for SNOBOL Intermediate Language, allowing it to be easily ported to any sufficiently powerful platform. This proposal was accepted as SNOBOL4 in September 1965. By this time, plans for a significantly improved version of the language emerged in August 1966.<sup id="cite_ref-FOOTNOTEGriswold1981608_7-0" class="reference"><a href="#cite_note-FOOTNOTEGriswold1981608-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> Further work on the language continued throughout the rest of the 1960s, notably adding the <a href="Associative_array" title="Associative array">associative array</a> type in later version, which they referred to as a table.
</p>
<div class="mw-heading mw-heading3"><h3 id="SL5_leads_to_Icon">SL5 leads to Icon</h3></div>
<p>Griswold left Bell Labs to become a professor at the <a href="University_of_Arizona" title="University of Arizona">University of Arizona</a> in August 1971.<sup id="cite_ref-FOOTNOTEGriswold1981609_8-0" class="reference"><a href="#cite_note-FOOTNOTEGriswold1981609-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> He introduced SNOBOL4 as a research tool at that time.<sup id="cite_ref-FOOTNOTEGriswold1981629_9-0" class="reference"><a href="#cite_note-FOOTNOTEGriswold1981629-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> He received grants from the <a href="National_Science_Foundation" title="National Science Foundation">National Science Foundation</a> to continue supporting and evolving SNOBOL.<sup id="cite_ref-FOOTNOTEShapiro1985346_10-0" class="reference"><a href="#cite_note-FOOTNOTEShapiro1985346-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup>
</p><p>As a language originally developed in the early 1960s, SNOBOL's syntax bears the marks of other early programming languages like <a href="FORTRAN" class="mw-redirect" title="FORTRAN">FORTRAN</a> and <a href="COBOL" title="COBOL">COBOL</a>. In particular, the language is column-dependant, as many of these languages were entered on <a href="Punch_card" class="mw-redirect" title="Punch card">punch cards</a> where column layout is natural. Additionally, control structures were almost entirely based on branching around code rather than the use of <a href="Block_(programming)" title="Block (programming)">blocks</a>, which were becoming a must-have feature after the introduction of <a href="ALGOL_60" title="ALGOL 60">ALGOL 60</a>. By the time he moved to Arizona, the syntax of SNOBOL4 was hopelessly outdated.<sup id="cite_ref-FOOTNOTEGriswoldGriswold199353_11-0" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold199353-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>
</p><p>Griswold began the effort of implementing SNOBOL's underlying success/failure concept with traditional flow control structures like if/then. This became SL5, short for "SNOBOL Language 5", but the result was unsatisfying.<sup id="cite_ref-FOOTNOTEGriswoldGriswold199353_11-1" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold199353-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> In 1977, he returned to the language to consider a new version. He abandoned the very powerful function system introduced in SL5 with a simpler concept of suspend/resume and developed a new concept for the natural successor to SNOBOL4 with the following principles;<sup id="cite_ref-FOOTNOTEGriswoldGriswold199353_11-2" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold199353-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>
</p>
<ul><li>SNOBOL4's philosophic and sematic basis</li>
<li>SL5 syntactic basis</li>
<li>SL5 features, excluding the generalized procedure mechanism</li></ul>
<p>The new language was initially known as SNOBOL5, but as it was significantly different from SNOBOL in all but the underlying concept, a new name was ultimately desired. After considering "s" as a sort of homage to "C", but this was ultimately abandoned due to the problems with typesetting documents using that name. A series of new names were proposed and abandoned; Irving, bard, and "TL" for "The Language". It was at this time that <a href="Xerox_PARC" class="mw-redirect" title="Xerox PARC">Xerox PARC</a> began publishing about their work on <a href="Graphical_user_interface" title="Graphical user interface">graphical user interfaces</a> and the term "icon" began to enter the computer lexicon. The decision was made to change the name initially to "icon" before finally choosing "Icon".<sup id="cite_ref-FOOTNOTEGriswoldGriswold199353_11-3" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold199353-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>a<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Language">Language</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Basic_syntax">Basic syntax</h3></div>
<p>The Icon language is derived from the <a href="ALGOL" title="ALGOL">ALGOL</a>-class of <a href="Structured_programming" title="Structured programming">structured programming</a> languages, and thus has syntax similar to <a href="C_(programming_language)" title="C (programming language)">C</a> or <a href="Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>. Icon is most similar to Pascal, using <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">:=</code> syntax for assignments, the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">procedure</code> keyword and similar syntax. On the other hand, Icon uses C-style braces for structuring execution groups, and programs start by running a procedure called <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">main</code>.<sup id="cite_ref-FOOTNOTEGriswoldGriswold2002xv_14-0" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold2002xv-14"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup>
</p><p>In many ways Icon also shares features with most <a href="Scripting_language" title="Scripting language">scripting languages</a> (as well as <a href="SNOBOL" title="SNOBOL">SNOBOL</a> and SL5, from which they were taken): variables do not have to be declared, types are cast automatically, and numbers can be converted to strings and back automatically.<sup id="cite_ref-FOOTNOTEGriswoldGriswold2002xvi_15-0" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold2002xvi-15"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> Another feature common to many scripting languages, but not all, is the lack of a line-ending character; in Icon, lines that do not end with a semicolon get ended by an implied semicolon if it makes sense.<sup id="cite_ref-FOOTNOTEGriswoldGriswold200210_16-0" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold200210-16"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup>
</p><p>Procedures are the basic building blocks of Icon programs. Although they use Pascal naming, they work more like C functions and can return values; there is no <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">function</code> keyword in Icon.<sup id="cite_ref-FOOTNOTEGriswoldGriswold20021_17-0" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold20021-17"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kd">procedure</span> <span class="nf">doSomething</span><span class="p">(</span><span class="nv">aString</span><span class="p">)</span>
<span class="nf">write</span><span class="p">(</span><span class="n">aString</span><span class="p">)</span>
<span class="kr">end</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Goal-directed_execution">Goal-directed execution</h3></div>
<p>One of the key concepts in SNOBOL was that its functions returned the "success" or "failure" as primitives of the language rather than using <a href="Magic_number_(programming)" title="Magic number (programming)">magic numbers</a> or other techniques.<sup id="cite_ref-FOOTNOTEGriswoldGriswold20024_18-0" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold20024-18"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTETratt201074_19-0" class="reference"><a href="#cite_note-FOOTNOTETratt201074-19"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</p><p>For example, a function that returns the position of a substring within another string is a common routine found in most language <a href="Runtime_system" title="Runtime system">runtime systems</a>. In <a href="JavaScript" title="JavaScript">JavaScript</a> to find the position of the word "World" within a <a href="%22Hello%2C_World!%22_program" title="&quot;Hello, World!&quot; program">"Hello, World!" program</a> would be accomplished with <code class="mw-highlight mw-highlight-lang-icon mw-content-ltr" style="" dir="ltr"><span class="n">position</span> <span class="o">=</span> <span class="s">"Hello, World"</span><span class="mf">.</span><span class="n">indexOf</span><span class="p">(</span><span class="s">"World"</span><span class="p">)</span></code>, which would return 7 in the variable <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">position</code>. If one instead asks for the <code class="mw-highlight mw-highlight-lang-icon mw-content-ltr" style="" dir="ltr"><span class="n">position</span> <span class="o">=</span> <span class="s">"Hello, World"</span><span class="mf">.</span><span class="n">indexOf</span><span class="p">(</span><span class="s">"Goodbye"</span><span class="p">)</span></code> the code will "fail", as the search term does not appear in the string. In JavaScript, as in most languages, this will be indicated by returning a magic number, in this case -1.<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup>
</p><p>In SNOBOL a failure of this sort returns a special value, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;fail</code>. SNOBOL's syntax operates directly on the success or failure of the operation, jumping to labelled sections of the code without having to write a separate test. For instance, the following code prints "Hello, world!" five times:<sup id="cite_ref-lane_21-0" class="reference"><a href="#cite_note-lane-21"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-snobol mw-content-ltr" dir="ltr"><pre><span class="c">* SNOBOL program to print Hello World</span>
<span class="n">I</span> <span class="o">=</span> <span class="mi">1</span>
<span class="nl">LOOP</span> <span class="nb">OUTPUT</span> <span class="o">=</span> <span class="s">"Hello, world!"</span>
<span class="n">I</span> <span class="o">=</span> <span class="n">I</span> <span class="o">+</span> <span class="mi">1</span>
<span class="nb">LE</span><span class="p">(</span><span class="n">I</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span> <span class="p">:</span> <span class="k">S</span><span class="p">(</span><span class="nl">LOOP</span><span class="p">)</span>
<span class="nl">END</span>
</pre></div>
<p>To perform the loop, the less-than-or-equal operator, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">LE</code>, is called on the index variable I, and if it <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">S</code>ucceeds, meaning I is less than 5, it branches to the named label <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">LOOP</code> and continues.<sup id="cite_ref-lane_21-1" class="reference"><a href="#cite_note-lane-21"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup>
</p><p>Icon retained the concept of flow control based on success or failure but developed the language further. One change was the replacement of the labelled <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">GOTO</code>-like branching with block-oriented structures in keeping with the <a href="Structured_programming" title="Structured programming">structured programming</a> style that was sweeping the computer industry in the late 1960s.<sup id="cite_ref-FOOTNOTEGriswoldGriswold199353_11-4" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold199353-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> The second was to allow "failure" to be passed along the call chain so that entire blocks will succeed or fail as a whole. This is a key concept of the Icon language. Whereas in traditional languages one would have to include code to test the success or failure based on <a href="Boolean_logic" class="mw-redirect" title="Boolean logic">Boolean logic</a> and then branch based on the outcome, such tests and branches are inherent to Icon code and do not have to be explicitly written.<sup id="cite_ref-FOOTNOTETratt201073_22-0" class="reference"><a href="#cite_note-FOOTNOTETratt201073-22"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup>
</p><p>For instance, consider this bit of code written in the <a href="Java_programming_language" class="mw-redirect" title="Java programming language">Java programming language</a>. It calls the function <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">read()</code> to read a character from a (previously opened) file, assigns the result to the variable <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a</code>, and then <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">write</code>s the value of <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a</code> to another file. The result is to copy one file to another. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">read</code> will eventually run out of characters to read from the file, potentially on its very first call, which would leave <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a</code> in an undetermined state and potentially cause <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">write</code> to cause a <a href="Null_pointer_exception" class="mw-redirect" title="Null pointer exception">null pointer exception</a>. To avoid this, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">read</code> returns the special value <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">EOF</code> (end-of-file) in this situation, which requires an explicit test to avoid <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">write</code>ing it:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="k">while</span><span class="w"> </span><span class="p">((</span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">read</span><span class="p">())</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">EOF</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">write</span><span class="p">(</span><span class="n">a</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
<p>In contrast, in Icon the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">read()</code> function returns a line of text or <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;fail</code>. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;fail</code> is not simply an analog of <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">EOF</code>, as it is explicitly understood by the language to mean "stop processing" or "do the fail case" depending on the context. The equivalent code in Icon is:<sup id="cite_ref-FOOTNOTETratt201074_19-1" class="reference"><a href="#cite_note-FOOTNOTETratt201074-19"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">while</span> <span class="n">a</span> <span class="o">:=</span> <span class="nf">read</span><span class="p">()</span> <span class="kr">do</span> <span class="nf">write</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
</pre></div>
<p>This means, "as long as read does not fail, call write, otherwise stop".<sup id="cite_ref-FOOTNOTETratt201074_19-2" class="reference"><a href="#cite_note-FOOTNOTETratt201074-19"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup> There is no need to specify a test against the magic number as in the Java example, this is implicit, and the resulting code is simplified. Because success and failure are passed up through the call chain, one can embed function calls within others and they stop when the <a href="Nested_function" title="Nested function">nested function</a> call fails. For instance, the code above can be reduced to:<sup id="cite_ref-FOOTNOTEGriswold19962.1_23-0" class="reference"><a href="#cite_note-FOOTNOTEGriswold19962.1-23"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">while</span> <span class="nf">write</span><span class="p">(</span><span class="nf">read</span><span class="p">())</span>
</pre></div>
<p>In this version, if the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">read</code> call fails, the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">write</code> call fails, and the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">while</code> stops.<sup id="cite_ref-FOOTNOTEGriswold19962.1_23-1" class="reference"><a href="#cite_note-FOOTNOTEGriswold19962.1-23"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup> Icon's branching and looping constructs are all based on the success or failure of the code inside them, not on an arbitrary Boolean test provided by the programmer. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">if</code> performs the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">then</code> block if its "test" returns a value, and performs the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">else</code> block or moves to the next line if it returns <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;fail</code>. Likewise, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">while</code> continues calling its block until it receives a fail. Icon refers to this concept as <b>goal-directed execution</b>.<sup id="cite_ref-FOOTNOTEGriswold19961_24-0" class="reference"><a href="#cite_note-FOOTNOTEGriswold19961-24"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup>
</p><p>It is important to contrast the concept of success and failure with the concept of an <a href="Exception_handling" title="Exception handling">exception</a>; exceptions are unusual situations, not expected outcomes. Fails in Icon are expected outcomes; reaching the end of a file is an expected situation and not an exception. Icon does not have exception handling in the traditional sense, although fail is often used in exception-like situations. For instance, if the file being read does not exist, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">read</code> fails without a special situation being indicated.<sup id="cite_ref-FOOTNOTETratt201074_19-3" class="reference"><a href="#cite_note-FOOTNOTETratt201074-19"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup> In traditional language, these "other conditions" have no natural way of being indicated; additional magic numbers may be used, but more typically exception handling is used to "throw" a value. For instance, to handle a missing file in the Java code, one might see:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="k">try</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">((</span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">read</span><span class="p">())</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">EOF</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">write</span><span class="p">(</span><span class="n">a</span><span class="p">);</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="n">Exception</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// something else went wrong, use this catch to exit the loop</span>
<span class="p">}</span>
</pre></div>
<p>This case needs two comparisons: one for EOF and another for all other errors. Since Java does not allow exceptions to be compared as logic elements, as under Icon, the lengthy <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">try/catch</code> syntax must be used instead. Try blocks also impose a performance penalty even if no exception is thrown, a <a href="Distributed_cost" title="Distributed cost">distributed cost</a> that Icon normally avoids.
</p><p>Icon uses this same goal-directed mechanism to perform traditional Boolean tests, although with subtle differences. A simple comparison like <code class="mw-highlight mw-highlight-lang-icon mw-content-ltr" style="" dir="ltr"><span class="kr">if</span> <span class="n">a</span> <span class="o">&lt;</span> <span class="n">b</span> <span class="kr">then</span> <span class="nf">write</span><span class="p">(</span><span class="s">"a is smaller than b"</span><span class="p">)</span></code> does not mean, "if the conditional expression evaluation results in or returns a true value" as they would under most languages; instead, it means something more like, "if the conditional expression succeeds and does not fail". In this case, the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&lt;</code> operator succeeds if the comparison is true. The <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">if</code> calls its <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">then</code> clause if the expression succeeds, and either the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">else</code> (if present) or the next line if it fails. The result is similar to the traditional if/then seen in other languages, the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">if</code> performs <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">then</code> if <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a</code> is less than <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">b</code>. The subtlety is that the same comparison expression can be placed anywhere, for instance:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="nf">write</span><span class="p">(</span><span class="n">a</span> <span class="o">&lt;</span> <span class="n">b</span><span class="p">)</span>
</pre></div>
<p>Another difference is that the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&lt;</code> operator returns its second argument if it succeeds, which in this example will result in the value of <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">b</code> being written if it is larger than <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a</code>, otherwise nothing is written. As this is not a test <i>per se</i>, but an operator that returns a value, they can be strung together allowing things like <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">if a &lt; b &lt; c</code>,<sup id="cite_ref-FOOTNOTEGriswold19962.1_23-2" class="reference"><a href="#cite_note-FOOTNOTEGriswold19962.1-23"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup> a common type of comparison that in most languages must be written as a conjunction of two inequalities like <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">if (a &lt; b) &amp;&amp; (b &lt; c)</code>.
</p><p>A key aspect of goal-directed execution is that the program may have to rewind to an earlier state if a procedure fails, a task known as <i>backtracking</i>. For instance, consider code that sets a variable to a starting location and then performs operations that may change the value - this is common in string scanning operations for instance, which will advance a cursor through the string as it scans. If the procedure fails, it is important that any subsequent reads of that variable return the original state, not the state as it was being internally manipulated. For this task, Icon has the <i>reversible assignment</i> operator, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&lt;-</code>, and the <i>reversible exchange</i>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&lt;-&gt;</code>. For instance, consider some code that is attempting to find a pattern string within a larger string:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="p">{</span>
<span class="p">(</span><span class="n">i</span> <span class="o">:=</span> <span class="mi">10</span><span class="p">)</span> <span class="o">&amp;</span>
<span class="p">(</span><span class="n">j</span> <span class="o">:=</span> <span class="p">(</span><span class="n">i</span> <span class="o">&lt;</span> <span class="nf">find</span><span class="p">(</span><span class="n">pattern</span><span class="p">,</span> <span class="n">inString</span><span class="p">)))</span>
<span class="p">}</span>
</pre></div>
<p>This code begins by moving <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i</code> to 10, the starting location for the search. However, if the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">find</code> fails, the block will fail as a whole, which results in the value of <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i</code> being left at 10 as an undesirable <a href="Side_effect_(computer_science)" title="Side effect (computer science)">side effect</a>. Replacing <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i&nbsp;:= 10</code> with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i &lt;- 10</code> indicates that <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i</code> should be reset to its previous value if the block fails. This provides an analog of <a href="Atomic_commit" title="Atomic commit">atomicity</a> in the execution.
</p>
<div class="mw-heading mw-heading3"><h3 id="Generators">Generators</h3></div>
<p>Expressions in Icon may return a single value, for instance, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">5 &gt; x</code> will evaluate and return x if the value of x is less than 5, otherwise it will fail and return no value. Icon also includes the concept of procedures that do not <i>immediately</i> return success or failure, and instead return new values every time they are called. These are known as <a href="Generator_(computer_programming)" title="Generator (computer programming)"><i>generators</i></a>, and are a key part of the Icon language. Within the parlance of Icon, the evaluation of an expression or function produces a <i>result sequence</i>. A result sequence contains all the possible values that can be generated by the expression or function. When the result sequence is exhausted, the expression or function fails.
</p><p>Icon allows any procedure to return a single value or multiple values, controlled using the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">fail</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">return</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">suspend</code> keywords. A procedure that lacks any of these keywords returns <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;fail</code>, which occurs whenever execution runs to the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">end</code> of a procedure. For instance:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kd">procedure</span> <span class="nf">f</span><span class="p">(</span><span class="nv">x</span><span class="p">)</span>
<span class="kr">if</span> <span class="n">x</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="kr">then</span> <span class="p">{</span>
<span class="kr">return</span> <span class="mi">1</span>
<span class="p">}</span>
<span class="kr">end</span>
</pre></div>
<p>Calling <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">f(5)</code> will return 1, but calling <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">f(-1)</code> will return <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;fail</code>. This can lead to non-obvious behavior, for instance, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">write(f(-1))</code> will output nothing because <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">f</code> fails and suspends operation of <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">write</code>.<sup id="cite_ref-FOOTNOTETratt201075_25-0" class="reference"><a href="#cite_note-FOOTNOTETratt201075-25"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup>
</p><p>Converting a procedure to be a generator uses the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">suspend</code> keyword, which means "return this value, and when called again, start execution at this point". In this respect it is something like a combination of the <a href="Static_(keyword)" title="Static (keyword)"><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">static</code></a> concept in C and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">return</code>. For instance:<sup id="cite_ref-FOOTNOTETratt201074_19-4" class="reference"><a href="#cite_note-FOOTNOTETratt201074-19"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kd">procedure</span> <span class="nf">ItoJ</span><span class="p">(</span><span class="nv">i</span><span class="p">,</span> <span class="nv">j</span><span class="p">)</span>
<span class="kr">while</span> <span class="n">i</span> <span class="o">&lt;=</span> <span class="n">j</span> <span class="kr">do</span> <span class="p">{</span>
<span class="kr">suspend</span> <span class="n">i</span>
<span class="n">i</span> <span class="o">+:=</span> <span class="mi">1</span>
<span class="p">}</span>
<span class="kr">fail</span>
<span class="kr">end</span>
</pre></div>
<p>creates a generator that returns a series of numbers starting at <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i</code> and ending a <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">j</code>, and then returns <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;fail</code> after that.<sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">[</span>b<span class="cite-bracket">]</span></a></sup> The <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">suspend i</code> stops execution and returns the value of <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i</code> without reseting any of the state. When another call is made to the same function, execution picks up at that point with the previous values. In this case, that causes it to perform <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i +:= 1</code>, loop back to the start of the while block, and then return the next value and suspend again. This continues until <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i &lt;= j</code> fails, at which point it exits the block and calls <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">fail</code>. This allows <a href="Iterator" title="Iterator">iterators</a> to be constructed with ease.<sup id="cite_ref-FOOTNOTETratt201074_19-5" class="reference"><a href="#cite_note-FOOTNOTETratt201074-19"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</p><p>Another type of generator-builder is the <i>alternator</i>, which looks and operates like the Boolean <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">or</code> operator. For instance:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">if</span> <span class="n">y</span> <span class="o">&lt;</span> <span class="p">(</span><span class="n">x</span> <span class="o">|</span> <span class="mi">5</span><span class="p">)</span> <span class="kr">then</span> <span class="nf">write</span><span class="p">(</span><span class="s">"y="</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
</pre></div>
<p>This appears to say "if y is smaller than x or 5 then...", but is actually a short-form for a generator that returns values until it falls off the end of the list. The values of the list are "injected" into the operations, in this case, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&lt;</code>. So in this example, the system first tests y &lt; x, if x is indeed larger than y it returns the value of x, the test passes, and the value of y is written out in the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">then</code> clause. However, if x is not larger than y it fails, and the alternator continues, performing y &lt; 5. If that test passes, y is written. If y is smaller than neither x or 5, the alternator runs out of tests and fails, the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">if</code> fails, and the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">write</code> is not performed. Thus, the value of y will appear on the console if it is smaller than x or 5, thereby fulfilling the purpose of a Boolean <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">or</code>. Functions will not be called unless evaluating their parameters succeeds, so this example can be shortened to:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="nf">write</span><span class="p">(</span><span class="s">"y="</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span> <span class="o">|</span> <span class="mi">5</span><span class="p">)</span> <span class="o">&gt;</span> <span class="n">y</span><span class="p">)</span>
</pre></div>
<p>Internally, the alternator is not simply an <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">or</code> and one can also use it to construct arbitrary lists of values. This can be used to iterate over arbitrary values, like:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">every</span> <span class="n">i</span> <span class="o">:=</span> <span class="p">(</span><span class="mi">1</span><span class="o">|</span><span class="mi">3</span><span class="o">|</span><span class="mi">4</span><span class="o">|</span><span class="mi">5</span><span class="o">|</span><span class="mi">10</span><span class="o">|</span><span class="mi">11</span><span class="o">|</span><span class="mi">23</span><span class="p">)</span> <span class="kr">do</span> <span class="nf">write</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
</pre></div>
<p>As lists of integers are commonly found in many programming contexts, Icon also includes the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">to</code> keyword to construct <i>ad hoc</i> integer generators:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre> <span class="kr">every</span> <span class="n">k</span> <span class="o">:=</span> <span class="n">i</span> <span class="kr">to</span> <span class="n">j</span> <span class="kr">do</span> <span class="nf">write</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
</pre></div>
<p>which can be shortened:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">every</span> <span class="nf">write</span><span class="p">(</span><span class="mi">1</span> <span class="kr">to</span> <span class="mi">10</span><span class="p">)</span>
</pre></div>
<p>Icon is not strongly typed, so the alternator lists can contain different types of items:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">every</span> <span class="n">i</span> <span class="o">:=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">|</span> <span class="s">"hello"</span> <span class="o">|</span> <span class="n">x</span> <span class="o">&lt;</span> <span class="mi">5</span><span class="p">)</span> <span class="kr">do</span> <span class="nf">write</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
</pre></div>
<p>This writes 1, "hello" and maybe 5 depending on the value of x.
</p><p>Likewise the <i>conjunction operator</i>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;</code>, is used in a fashion similar to a Boolean <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">and</code> operator:<sup id="cite_ref-FOOTNOTETratt201076_27-0" class="reference"><a href="#cite_note-FOOTNOTETratt201076-27"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">every</span> <span class="n">x</span> <span class="o">:=</span> <span class="n">ItoJ</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">10</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">x</span> <span class="p">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">0</span> <span class="kr">do</span> <span class="nf">write</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
</pre></div>
<p>This code calls <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">ItoJ</code> and returns an initial value of 0 which is assigned to x. It then performs the right-hand side of the conjunction, and since <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">x&nbsp;% 2</code> does equal 0, it writes out the value. It then calls the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">ItoJ</code> generator again which assigns 1 to x, which fails the right-hand-side and prints nothing. The result is a list of every even integer from 0 to 10.<sup id="cite_ref-FOOTNOTETratt201076_27-1" class="reference"><a href="#cite_note-FOOTNOTETratt201076-27"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup>
</p><p>The concept of generators is particularly useful and powerful when used with string operations, and is a major underlying basis for Icon's overall design. Consider the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">indexOf</code> operation found in many languages; this function looks for one string within another and returns an index of its location, or a magic number if it is not found. For instance:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"All the world's a stage. And all the men and women merely players"</span><span class="p">;</span>
<span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">indexOf</span><span class="p">(</span><span class="s">"the"</span><span class="p">,</span><span class="w"> </span><span class="n">s</span><span class="p">);</span>
<span class="n">write</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
</pre></div>
<p>This will scan the string <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">s</code>, find the first occurrence of "the", and return that index, in this case 4. The string, however, contains two instances of the string "the", so to return the second example an alternate syntax is used:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="n">j</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">indexOf</span><span class="p">(</span><span class="s">"the"</span><span class="p">,</span><span class="w"> </span><span class="n">s</span><span class="p">,</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span>
<span class="n">write</span><span class="p">(</span><span class="n">j</span><span class="p">);</span>
</pre></div>
<p>This tells it to scan starting at location 5, so it will not match the first instance we found previously. However, there may not be a second instance of "the" -there may not be a first one either- so the return value from <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">indexOf</code> has to be checked against the magic number -1 which is used to indicate no matches. A complete routine that prints out the location of every instance is:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"All the world's a stage. And all the men and women merely players"</span><span class="p">;</span>
<span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">indexOf</span><span class="p">(</span><span class="s">"the"</span><span class="p">,</span><span class="w"> </span><span class="n">s</span><span class="p">);</span>
<span class="k">while</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="o">-</span><span class="mi">1</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">write</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
<span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">indexOf</span><span class="p">(</span><span class="s">"the"</span><span class="p">,</span><span class="w"> </span><span class="n">s</span><span class="p">,</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
<p>In Icon, the equivalent <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">find</code> is a generator, so the same results can be created with a single line:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">s</span> <span class="o">:=</span> <span class="s">"All the world's a stage. And all the men and women merely players"</span>
<span class="kr">every</span> <span class="nf">write</span><span class="p">(</span><span class="nf">find</span><span class="p">(</span><span class="s">"the"</span><span class="p">,</span> <span class="n">s</span><span class="p">))</span>
</pre></div>
<p>Of course there are times where one does want to find a string after some point in input, for instance, if scanning a <a href="Text_file" title="Text file">text file</a> that contains a line number in the first four columns, a space, and then a line of text. Goal-directed execution can be used to skip over the line numbers:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">every</span> <span class="nf">write</span><span class="p">(</span><span class="mi">5</span> <span class="o">&lt;</span> <span class="nf">find</span><span class="p">(</span><span class="s">"the"</span><span class="p">,</span> <span class="n">s</span><span class="p">))</span>
</pre></div>
<p>The position will only be returned if "the" appears after position 5; the comparison will fail otherwise, pass the fail to write, and the write will not occur.
</p><p>The <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">every</code> operator is similar to <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">while</code>, looping through every item returned by a generator and exiting on failure:<sup id="cite_ref-FOOTNOTETratt201075_25-1" class="reference"><a href="#cite_note-FOOTNOTETratt201075-25"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">every</span> <span class="n">k</span> <span class="o">:=</span> <span class="n">i</span> <span class="kr">to</span> <span class="n">j</span> <span class="kr">do</span>
<span class="nf">write</span><span class="p">(</span><span class="n">someFunction</span><span class="p">(</span><span class="n">k</span><span class="p">))</span>
</pre></div>
<p>There is a key difference between <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">every</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">while</code>; <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">while</code> re-evaluates the first result until it fails, whereas <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">every</code> fetches the next value from a generator. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">every</code> actually injects values into the function in a fashion similar to blocks under <a href="Smalltalk" title="Smalltalk">Smalltalk</a>. For instance, the above loop can be re-written this way:<sup id="cite_ref-FOOTNOTETratt201075_25-2" class="reference"><a href="#cite_note-FOOTNOTETratt201075-25"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">every</span> <span class="nf">write</span><span class="p">(</span><span class="n">someFunction</span><span class="p">(</span><span class="n">i</span> <span class="kr">to</span> <span class="n">j</span><span class="p">))</span>
</pre></div>
<p>In this case, the values from i to j will be injected into <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">someFunction</code> and (potentially) write multiple lines of output.<sup id="cite_ref-FOOTNOTETratt201075_25-3" class="reference"><a href="#cite_note-FOOTNOTETratt201075-25"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Collections">Collections</h3></div>
<p>Icon includes several <a href="Collection_(abstract_data_type)" title="Collection (abstract data type)">collection types</a> including <a href="List_(abstract_data_type)" title="List (abstract data type)">lists</a> that can also be used as <a href="Stack_(abstract_data_type)" title="Stack (abstract data type)">stacks</a> and <a href="Queue_(abstract_data_type)" title="Queue (abstract data type)">queues</a>, <a href="Associative_array" title="Associative array">tables</a> (also known as maps or dictionaries in other languages), <a href="Set_(abstract_data_type)" title="Set (abstract data type)">sets</a> and others. Icon refers to these as <i>structures</i>. Collections are inherent generators and can be easily called using the bang syntax. For instance:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">lines</span> <span class="o">:=</span> <span class="p">[]</span> <span class="c1"># create an empty list</span>
<span class="kr">while</span> <span class="n">line</span> <span class="o">:=</span> <span class="nf">read</span><span class="p">()</span> <span class="kr">do</span> <span class="p">{</span> <span class="c1"># loop reading lines from standard input</span>
<span class="nf">push</span><span class="p">(</span><span class="n">lines</span><span class="p">,</span> <span class="n">line</span><span class="p">)</span> <span class="c1"># use stack-like syntax to push the line on the list</span>
<span class="p">}</span>
<span class="kr">while</span> <span class="n">line</span> <span class="o">:=</span> <span class="nf">pop</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="kr">do</span> <span class="p">{</span> <span class="c1"># loop while lines can be popped off the list</span>
<span class="nf">write</span><span class="p">(</span><span class="n">line</span><span class="p">)</span> <span class="c1"># write the line out</span>
<span class="p">}</span>
</pre></div>
<p>Using the fail propagation as seen in earlier examples, we can combine the tests and the loops:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">lines</span> <span class="o">:=</span> <span class="p">[]</span> <span class="c1"># create an empty list</span>
<span class="kr">while</span> <span class="nf">push</span><span class="p">(</span><span class="n">lines</span><span class="p">,</span> <span class="nf">read</span><span class="p">())</span> <span class="c1"># push until empty</span>
<span class="kr">while</span> <span class="nf">write</span><span class="p">(</span><span class="nf">pop</span><span class="p">(</span><span class="n">lines</span><span class="p">))</span> <span class="c1"># write until empty</span>
</pre></div>
<p>Because the list collection is a generator, this can be further simplified with the bang syntax:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">lines</span> <span class="o">:=</span> <span class="p">[]</span>
<span class="kr">every</span> <span class="nf">push</span><span class="p">(</span><span class="n">lines</span><span class="p">,</span> <span class="o">!</span><span class="kr">&amp;input</span><span class="p">)</span>
<span class="kr">every</span> <span class="nf">write</span><span class="p">(</span><span class="o">!</span><span class="n">lines</span><span class="p">)</span>
</pre></div>
<p>In this case, the bang in <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">write</code> causes Icon to return a line of text one by one from the array and finally fail at the end. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;input</code> is a generator-based analog of <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">read</code> that reads a line from <a href="Standard_input" class="mw-redirect" title="Standard input">standard input</a>, so <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">!&amp;input</code> continues reading lines until the file ends.
</p><p>As Icon is typeless, lists can contain any different types of values:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">aCat</span> <span class="o">:=</span> <span class="p">[</span><span class="s">"muffins"</span><span class="p">,</span> <span class="s">"tabby"</span><span class="p">,</span> <span class="mi">2002</span><span class="p">,</span> <span class="mi">8</span><span class="p">]</span>
</pre></div>
<p>The items can included other structures. To build larger lists, Icon includes the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">list</code> generator; <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">i&nbsp;:= list(10, "word")</code> generates a list containing 10 copies of "word". Like arrays in other languages, Icon allows items to be looked up by position, e.g., <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">weight&nbsp;:= aCat[4]</code>. <a href="Array_slicing" title="Array slicing">Array slicing</a> is included, allowing new lists to be created out of the elements of other lists, for instance, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">aCat&nbsp;:= Cats[2:4]</code> produces a new list called aCat that contains "tabby" and 2002.
</p><p>Tables are essentially lists with arbitrary index keys rather than integers:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">symbols</span> <span class="o">:=</span> <span class="nf">table</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="n">symbols</span><span class="p">[</span><span class="s">"there"</span><span class="p">]</span> <span class="o">:=</span> <span class="mi">1</span>
<span class="n">symbols</span><span class="p">[</span><span class="s">"here"</span><span class="p">]</span> <span class="o">:=</span> <span class="mi">2</span>
</pre></div>
<p>This code creates a table that will use zero as the default value of any unknown key. It then adds two items into the table, with the keys "there" and "here", and values 1 and 2.
</p><p>Sets are also similar to lists but contain only a single member of any given value. Icon includes the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">++</code> to produce the union of two sets, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">**</code> the intersection, and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">--</code> the difference. Icon includes a number of pre-defined "Cset"s, a set containing various characters. There are four standard Csets in Icon, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;ucase</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;lcase</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;letters</code>, and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;digits</code>. New Csets can be made by enclosing a string in single quotes, for instance, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">vowel&nbsp;:= 'aeiou'</code>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Strings">Strings</h3></div>
<p>In Icon, strings are lists of characters. As a list, they are generators and can thus be iterated over using the bang syntax:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kr">every</span> <span class="nf">write</span><span class="p">(</span><span class="o">!</span><span class="s">"Hello, world!"</span><span class="p">)</span>
</pre></div>
<p>Will print out each character of the string on a separate line.
</p><p>Substrings can be extracted from a string by using a range specification within brackets. A range specification can return a point to a single character, or a <a href="Array_slicing" title="Array slicing">slice</a> of the string. Strings can be indexed from either the right or the left. Positions within a string are defined to be <b>between</b> the characters <sub>1</sub>A<sub>2</sub>B<sub>3</sub>C<sub>4</sub> and can be specified from the right <sub>−3</sub>A<sub>−2</sub>B<sub>−1</sub>C<sub>0</sub>
</p><p>For example,
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="s">"Wikipedia"</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==&gt;</span> <span class="s">"W"</span>
<span class="s">"Wikipedia"</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">==&gt;</span> <span class="s">"k"</span>
<span class="s">"Wikipedia"</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==&gt;</span> <span class="s">"a"</span>
<span class="s">"Wikipedia"</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="mi">3</span><span class="p">]</span> <span class="o">==&gt;</span> <span class="s">"Wi"</span>
<span class="s">"Wikipedia"</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">:</span><span class="mi">0</span><span class="p">]</span> <span class="o">==&gt;</span> <span class="s">"ia"</span>
<span class="s">"Wikipedia"</span><span class="p">[</span><span class="mi">2</span><span class="o">+</span><span class="p">:</span><span class="mi">3</span><span class="p">]</span> <span class="o">==&gt;</span> <span class="s">"iki"</span>
</pre></div>
<p>Where the last example shows using a length instead of an ending position
</p><p>The subscripting specification can be used as a <a href="Value_(computer_science)#lrvalue" title="Value (computer science)">lvalue</a> within an expression. This can be used to insert strings into another string or delete parts of a string. For example:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">s</span> <span class="o">:=</span> <span class="s">"abc"</span>
<span class="n">s</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">:=</span> <span class="s">"123"</span>
<span class="n">s</span> <span class="n">now</span> <span class="n">has</span> <span class="n">a</span> <span class="n">value</span> <span class="kr">of</span> <span class="s">"a123c"</span>
<span class="n">s</span> <span class="o">:=</span> <span class="s">"abcdefg"</span>
<span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">:</span><span class="mi">5</span><span class="p">]</span> <span class="o">:=</span> <span class="s">"ABCD"</span>
<span class="n">s</span> <span class="n">now</span> <span class="n">has</span> <span class="n">a</span> <span class="n">value</span> <span class="kr">of</span> <span class="s">"abABCDefg"</span>
<span class="n">s</span> <span class="o">:=</span> <span class="s">"abcdefg"</span>
<span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">:</span><span class="mi">5</span><span class="p">]</span> <span class="o">:=</span> <span class="s">""</span>
<span class="n">s</span> <span class="n">now</span> <span class="n">has</span> <span class="n">a</span> <span class="n">value</span> <span class="kr">of</span> <span class="s">"abefg"</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="String_scanning">String scanning</h3></div>
<p>A further simplification for handling strings is the <i>scanning</i> system, invoked with <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">?</code>, which calls functions on a string:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">s</span> <span class="o">?</span> <span class="nf">write</span><span class="p">(</span><span class="nf">find</span><span class="p">(</span><span class="s">"the"</span><span class="p">))</span>
</pre></div>
<p>Icon refers to the left-hand-side of the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">?</code> as the <i>subject</i>, and passes it into string functions. Recall the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">find</code> takes two parameters, the search text as parameter one and the string to search in parameter two. Using <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">?</code> the second parameter is implicit and does not have to be specified by the programmer. In the common cases when multiple functions are being called on a single string in sequence, this style can significantly reduce the length of the resulting code and improve clarity. Icon function signatures identify the subject parameter in their definitions so the parameter can be <a href="Loop-invariant_code_motion" title="Loop-invariant code motion">hoisted</a> in this fashion.
</p><p>The <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">?</code> is not simply a form of <a href="Syntactic_sugar" title="Syntactic sugar">syntactic sugar</a>, it also sets up a "string scanning environment" for any following string operations. This is based on two internal variables, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;subject</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code>; <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;subject</code> is simply a pointer to the original string, while <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code> is the current position within it, or cursor. Icon's various string manipulation procedures use these two variables so they do not have to be explicitly supplied by the programmer. For example:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">s</span> <span class="o">:=</span> <span class="s">"this is a string"</span>
<span class="n">s</span> <span class="o">?</span> <span class="nf">write</span><span class="p">(</span><span class="s">"subject=["</span><span class="p">,</span><span class="kr">&amp;subject</span><span class="p">,</span><span class="s">"], pos=["</span><span class="p">,</span><span class="kr">&amp;pos</span><span class="p">,</span><span class="s">"]"</span><span class="p">)</span>
</pre></div>
<p>would produce:
</p>
<div class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr"><pre>subject=[this is a string], pos=[1]
</pre></div>
<p>Built-in and user-defined functions can be used to move around within the string being scanned. All of the built-in functions will default to <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;subject</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code> to allow the scanning syntax to be used. The following code will write all blank-delimited "words" in a string:
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">s</span> <span class="o">:=</span> <span class="s">"this is a string"</span>
<span class="n">s</span> <span class="o">?</span> <span class="p">{</span> <span class="c1"># Establish string scanning environment</span>
<span class="kr">while</span> <span class="kr">not</span> <span class="nf">pos</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="kr">do</span> <span class="p">{</span> <span class="c1"># Test for end of string</span>
<span class="nf">tab</span><span class="p">(</span><span class="nf">many</span><span class="p">(</span><span class="s s-Character">' '</span><span class="p">))</span> <span class="c1"># Skip past any blanks</span>
<span class="n">word</span> <span class="o">:=</span> <span class="nf">tab</span><span class="p">(</span><span class="nf">upto</span><span class="p">(</span><span class="s s-Character">' '</span><span class="p">)</span> <span class="o">|</span> <span class="mi">0</span><span class="p">)</span> <span class="c1"># the next word is up to the next blank -or- the end of the line</span>
<span class="nf">write</span><span class="p">(</span><span class="n">word</span><span class="p">)</span> <span class="c1"># write the word</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
<p>There are a number of new functions introduced in this example. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">pos</code> returns the current value of <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code>. It may not be immediately obvious why one would need this function and not simply use the value of <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code> directly; the reason is that <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code> is a variable and thus cannot take on the value <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;fail</code>, which the procedure <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">pos</code> can. Thus <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">pos</code> provides a lightweight wrapper on <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code> that allows Icon's goal-directed flow control to be easily used without having to provide hand-written Boolean tests against <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code>. In this case, the test is "is &amp;pos zero", which, in the odd numbering of Icon's string locations, is the end of the line. If it is <i>not</i> zero, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">pos</code> returns <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;fail</code>, which is inverted with the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">not</code> and the loop continues.
</p><p><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">many</code> finds one or more examples of the provided Cset parameter starting at the current <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code>. In this case, it is looking for space characters, so the result of this function is the location of the first non-space character after <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code>. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">tab</code> moves <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code> to that location, again with a potential <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;fail</code> in case, for instance, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">many</code> falls off the end of the string. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">upto</code> is essentially the reverse of <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">many</code>; it returns the location immediately prior to its provided Cset, which the example then sets the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;pos</code> to with another <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">tab</code>. Alternation is used to also stop at the end of a line.
</p><p>This example can be made more robust through the use of a more appropriate "word breaking" Cset which might include periods, commas and other punctuation, as well as other whitespace characters like tab and non-breaking spaces. That Cset can then be used in <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">many</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">upto</code>.
</p><p>A more complex example demonstrates the integration of generators and string scanning within the language.
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kd">procedure</span> <span class="nf">main</span><span class="p">()</span>
<span class="n">s</span> <span class="o">:=</span> <span class="s">"Mon Dec 8"</span>
<span class="n">s</span> <span class="o">?</span> <span class="nf">write</span><span class="p">(</span><span class="n">Mdate</span><span class="p">()</span> <span class="o">|</span> <span class="s">"not a valid date"</span><span class="p">)</span>
<span class="kr">end</span>
<span class="c1"># Define a matching function that returns</span>
<span class="c1"># a string that matches a day month dayofmonth</span>
<span class="kd">procedure</span> <span class="nf">Mdate</span><span class="p">()</span>
<span class="c1"># Define some initial values</span>
<span class="kr">static</span> <span class="n">dates</span>
<span class="kr">static</span> <span class="n">days</span>
<span class="kr">initial</span> <span class="p">{</span>
<span class="n">days</span> <span class="o">:=</span> <span class="p">[</span><span class="s">"Mon"</span><span class="p">,</span><span class="s">"Tue"</span><span class="p">,</span><span class="s">"Wed"</span><span class="p">,</span><span class="s">"Thr"</span><span class="p">,</span><span class="s">"Fri"</span><span class="p">,</span><span class="s">"Sat"</span><span class="p">,</span><span class="s">"Sun"</span><span class="p">]</span>
<span class="n">months</span> <span class="o">:=</span> <span class="p">[</span><span class="s">"Jan"</span><span class="p">,</span><span class="s">"Feb"</span><span class="p">,</span><span class="s">"Mar"</span><span class="p">,</span><span class="s">"Apr"</span><span class="p">,</span><span class="s">"May"</span><span class="p">,</span><span class="s">"Jun"</span><span class="p">,</span>
<span class="s">"Jul"</span><span class="p">,</span><span class="s">"Aug"</span><span class="p">,</span><span class="s">"Sep"</span><span class="p">,</span><span class="s">"Oct"</span><span class="p">,</span><span class="s">"Nov"</span><span class="p">,</span><span class="s">"Dec"</span><span class="p">]</span>
<span class="p">}</span>
<span class="kr">every</span> <span class="kr">suspend</span> <span class="p">(</span><span class="n">retval</span> <span class="o">&lt;-</span> <span class="nf">tab</span><span class="p">(</span><span class="nf">match</span><span class="p">(</span><span class="o">!</span><span class="n">days</span><span class="p">))</span> <span class="o">||</span> <span class="c1"># Match a day</span>
<span class="o">=</span><span class="s">" "</span> <span class="o">||</span> <span class="c1"># Followed by a blank</span>
<span class="nf">tab</span><span class="p">(</span><span class="nf">match</span><span class="p">(</span><span class="o">!</span><span class="n">months</span><span class="p">))</span> <span class="o">||</span> <span class="c1"># Followed by the month</span>
<span class="o">=</span><span class="s">" "</span> <span class="o">||</span> <span class="c1"># Followed by a blank</span>
<span class="n">matchdigits</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="c1"># Followed by at least 2 digits</span>
<span class="p">)</span> <span class="o">&amp;</span>
<span class="p">(</span><span class="o">=</span><span class="s">" "</span> <span class="o">|</span> <span class="nf">pos</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="p">)</span> <span class="o">&amp;</span> <span class="c1"># Either a blank or the end of the string</span>
<span class="n">retval</span> <span class="c1"># And finally return the string</span>
<span class="kr">end</span>
<span class="c1"># Matching function that returns a string of n digits</span>
<span class="kd">procedure</span> <span class="nf">matchdigits</span><span class="p">(</span><span class="nv">n</span><span class="p">)</span>
<span class="kr">suspend</span> <span class="p">(</span><span class="n">v</span> <span class="o">:=</span> <span class="nf">tab</span><span class="p">(</span><span class="nf">many</span><span class="p">(</span><span class="kr">&amp;digits</span><span class="p">))</span> <span class="o">&amp;</span> <span class="o">*</span><span class="n">v</span> <span class="o">&lt;=</span> <span class="n">n</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">v</span>
<span class="kr">end</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="Criticisms">Criticisms</h2></div>
<p>Laurence Tratt wrote a paper on Icon examining its real-world applications and pointing out a number of areas of concern. Among these were a number of practical decisions that derive from their origins in string processing but do not make as much sense in other areas.<sup id="cite_ref-FOOTNOTETratt201075_25-4" class="reference"><a href="#cite_note-FOOTNOTETratt201075-25"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup> Among them:
</p><p>The decision to fail by default at the end of procedures makes sense in the context of generators, but less so in the case of general procedures. Returning to the example noted above, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">write(f(-1))</code> will not output which may be expected. However:<sup id="cite_ref-FOOTNOTETratt201075_25-5" class="reference"><a href="#cite_note-FOOTNOTETratt201075-25"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="n">x</span> <span class="o">:=</span> <span class="mi">10</span>
<span class="p">(</span><span class="n">additional</span> <span class="n">lines</span><span class="p">)</span>
<span class="n">x</span> <span class="o">:=</span> <span class="n">f</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="nf">write</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
</pre></div>
<p>will result in 10 being printed. This sort of issue is not at all obvious as even in an interactive debugger all the code is invoked yet <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">x</code> never picks up the expected value. This could be dismissed as one of those "gotchas" that programmers have to be aware of in any language, but Tratt examined a variety of Icon programs and found that the vast majority of procedures are not generators. This means that Icon's default behaviour is only used by a tiny minority of its constructs, yet represents a major source of potential errors in all the others.<sup id="cite_ref-FOOTNOTETratt201075_25-6" class="reference"><a href="#cite_note-FOOTNOTETratt201075-25"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup>
</p><p>Another issue is the lack of a Boolean data type<sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>c<span class="cite-bracket">]</span></a></sup> and conventional Boolean logic. While the success/fail system works in most cases where the ultimate goal is to check a value, this can still lead to some odd behaviour in seemingly simple code:<sup id="cite_ref-FOOTNOTETratt201076_27-2" class="reference"><a href="#cite_note-FOOTNOTETratt201076-27"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-icon mw-content-ltr" dir="ltr"><pre><span class="kd">procedure</span> <span class="nf">main</span><span class="p">()</span>
<span class="kr">if</span> <span class="n">c</span> <span class="kr">then</span> <span class="p">{</span>
<span class="nf">write</span><span class="p">(</span><span class="s">"taken"</span><span class="p">)</span>
<span class="p">}</span>
<span class="kr">end</span>
</pre></div>
<p>This program will print "taken". The reason is that the test, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">c</code>, does return a value; that value is <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;null</code>, the default value for all otherwise uninitiated variables.<sup id="cite_ref-FOOTNOTEGriswoldGriswold2002128_29-0" class="reference"><a href="#cite_note-FOOTNOTEGriswoldGriswold2002128-29"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup> <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">&amp;null</code> is a valid value, so <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">if c</code> succeeds. To test this, one needs to make the test explicit, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">c === &amp;null</code>. Tratt supposed that it detracts from the self-documenting code, having supposed erroneously that it is testing "is c zero" or "does c exist".<sup id="cite_ref-FOOTNOTETratt201076_27-3" class="reference"><a href="#cite_note-FOOTNOTETratt201076-27"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Coroutine" title="Coroutine">Coroutine</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist reflist-lower-alpha">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text">According to an interview in 1985, Griswold states that the term 'icon' was not being used until <a href="Smalltalk" title="Smalltalk">Smalltalk</a> was released to the public some time later. He expressed his annoyance that the term was now confusing people who thought the language had graphical elements.<sup id="cite_ref-FOOTNOTEShapiro1985350_12-0" class="reference"><a href="#cite_note-FOOTNOTEShapiro1985350-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup></span>
</li>
<li id="cite_note-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-26">^</a></b></span> <span class="reference-text">The <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">fail</code> is not <i>required</i> in this case as it is immediately before the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">end</code>. It has been added for clarity.</span>
</li>
<li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text">Although, as Tratt points out, K&amp;R C also lacks an explicit Boolean type and uses 0 for false and any non-zero for true.<sup id="cite_ref-FOOTNOTETratt201075_25-7" class="reference"><a href="#cite_note-FOOTNOTETratt201075-25"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Citations">Citations</h3></div>
<div class="reflist reflist-columns references-column-width" style="column-width: 30em;">
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFTownsend2024" class="citation web cs1">Townsend, Gregg (January 26, 2024). <a rel="nofollow" class="external text" href="https://github.com/gtownsend/icon/commits/master">"Update version to 9.5.22e"</a>. <i><a href="GitHub" title="GitHub">GitHub</a></i>.</cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/proebsting/goaldi">"Goaldi"</a>. <i><a href="GitHub" title="GitHub">GitHub</a></i>.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite id="CITEREFSchemenauerPetersHetland2001" class="citation web cs1">Schemenauer, Neil; Peters, Tim; Hetland, Magnus Lie (18 May 2001). <a rel="nofollow" class="external text" href="https://www.python.org/dev/peps/pep-0255/">"PEP 255 – Simple Generators"</a>. <i>Python Enhancement Proposals</i>. Python Software Foundation<span class="reference-accessdate">. Retrieved <span class="nowrap">9 February</span> 2012</span>.</cite></span>
</li>
<li id="cite_note-FOOTNOTEGriswold1981601,_602-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswold1981601,_602_4-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswold1981">Griswold 1981</a>, pp.&nbsp;601, 602.</span>
</li>
<li id="cite_note-FOOTNOTEGriswold1981602-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswold1981602_5-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswold1981">Griswold 1981</a>, pp.&nbsp;602.</span>
</li>
<li id="cite_note-FOOTNOTEGriswold1981606-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswold1981606_6-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswold1981">Griswold 1981</a>, pp.&nbsp;606.</span>
</li>
<li id="cite_note-FOOTNOTEGriswold1981608-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswold1981608_7-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswold1981">Griswold 1981</a>, pp.&nbsp;608.</span>
</li>
<li id="cite_note-FOOTNOTEGriswold1981609-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswold1981609_8-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswold1981">Griswold 1981</a>, pp.&nbsp;609.</span>
</li>
<li id="cite_note-FOOTNOTEGriswold1981629-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswold1981629_9-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswold1981">Griswold 1981</a>, pp.&nbsp;629.</span>
</li>
<li id="cite_note-FOOTNOTEShapiro1985346-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEShapiro1985346_10-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFShapiro1985">Shapiro 1985</a>, pp.&nbsp;346.</span>
</li>
<li id="cite_note-FOOTNOTEGriswoldGriswold199353-11"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEGriswoldGriswold199353_11-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEGriswoldGriswold199353_11-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEGriswoldGriswold199353_11-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-FOOTNOTEGriswoldGriswold199353_11-3"><sup><i><b>d</b></i></sup></a> <a href="#cite_ref-FOOTNOTEGriswoldGriswold199353_11-4"><sup><i><b>e</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFGriswoldGriswold1993">Griswold &amp; Griswold 1993</a>, p.&nbsp;53.</span>
</li>
<li id="cite_note-FOOTNOTEShapiro1985350-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEShapiro1985350_12-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFShapiro1985">Shapiro 1985</a>, p.&nbsp;350.</span>
</li>
<li id="cite_note-FOOTNOTEGriswoldGriswold2002xv-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswoldGriswold2002xv_14-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswoldGriswold2002">Griswold &amp; Griswold 2002</a>, p.&nbsp;xv.</span>
</li>
<li id="cite_note-FOOTNOTEGriswoldGriswold2002xvi-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswoldGriswold2002xvi_15-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswoldGriswold2002">Griswold &amp; Griswold 2002</a>, p.&nbsp;xvi.</span>
</li>
<li id="cite_note-FOOTNOTEGriswoldGriswold200210-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswoldGriswold200210_16-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswoldGriswold2002">Griswold &amp; Griswold 2002</a>, p.&nbsp;10.</span>
</li>
<li id="cite_note-FOOTNOTEGriswoldGriswold20021-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswoldGriswold20021_17-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswoldGriswold2002">Griswold &amp; Griswold 2002</a>, p.&nbsp;1.</span>
</li>
<li id="cite_note-FOOTNOTEGriswoldGriswold20024-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswoldGriswold20024_18-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswoldGriswold2002">Griswold &amp; Griswold 2002</a>, p.&nbsp;4.</span>
</li>
<li id="cite_note-FOOTNOTETratt201074-19"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTETratt201074_19-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201074_19-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201074_19-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201074_19-3"><sup><i><b>d</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201074_19-4"><sup><i><b>e</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201074_19-5"><sup><i><b>f</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFTratt2010">Tratt 2010</a>, p.&nbsp;74.</span>
</li>
<li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf">"Array.prototype.indexOf()"</a>. <i>MDN Web Docs</i>. 27 June 2023.</cite></span>
</li>
<li id="cite_note-lane-21"><span class="mw-cite-backlink">^ <a href="#cite_ref-lane_21-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-lane_21-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFLane2015" class="citation web cs1">Lane, Rupert (26 July 2015). <a rel="nofollow" class="external text" href="https://try-mts.com/snobol-introduction/">"SNOBOL - Introduction"</a>. <i>Try MTS</i>.</cite></span>
</li>
<li id="cite_note-FOOTNOTETratt201073-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTETratt201073_22-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFTratt2010">Tratt 2010</a>, p.&nbsp;73.</span>
</li>
<li id="cite_note-FOOTNOTEGriswold19962.1-23"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEGriswold19962.1_23-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEGriswold19962.1_23-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEGriswold19962.1_23-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFGriswold1996">Griswold 1996</a>, p.&nbsp;2.1.</span>
</li>
<li id="cite_note-FOOTNOTEGriswold19961-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswold19961_24-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswold1996">Griswold 1996</a>, p.&nbsp;1.</span>
</li>
<li id="cite_note-FOOTNOTETratt201075-25"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTETratt201075_25-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201075_25-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201075_25-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201075_25-3"><sup><i><b>d</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201075_25-4"><sup><i><b>e</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201075_25-5"><sup><i><b>f</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201075_25-6"><sup><i><b>g</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201075_25-7"><sup><i><b>h</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFTratt2010">Tratt 2010</a>, p.&nbsp;75.</span>
</li>
<li id="cite_note-FOOTNOTETratt201076-27"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTETratt201076_27-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201076_27-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201076_27-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-FOOTNOTETratt201076_27-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFTratt2010">Tratt 2010</a>, p.&nbsp;76.</span>
</li>
<li id="cite_note-FOOTNOTEGriswoldGriswold2002128-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEGriswoldGriswold2002128_29-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFGriswoldGriswold2002">Griswold &amp; Griswold 2002</a>, p.&nbsp;128.</span>
</li>
</ol></div>
<div class="mw-heading mw-heading3"><h3 id="Bibliography">Bibliography</h3></div>
<ul><li><cite id="CITEREFGriswoldGriswold2002" class="citation book cs1">Griswold, Ralph; Griswold, Madge (2002). <a rel="nofollow" class="external text" href="https://www2.cs.arizona.edu/icon/books.htm"><i>The Icon Programming Language</i></a> (third&nbsp;ed.). Peer-to-Peer Communications. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>1-57398-001-3</bdi>.</cite></li>
<li><cite id="CITEREFGriswoldGriswold1993" class="citation journal cs1">Griswold, Ralph; Griswold, Madge (March 1993). <a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F155360.155363">"History of the Icon Programming Language"</a>. <i>SIGPLAN Notices</i>. <b>23</b> (3): <span class="nowrap">53–</span>68. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F155360.155363">10.1145/155360.155363</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:861936">861936</a>.</cite></li>
<li><cite id="CITEREFGriswold1981" class="citation book cs1">Griswold, Ralph (1981). <a rel="nofollow" class="external text" href="https://doi.org/10.1145/800025.1198417">"A History of the SNOBOL Programming Languages"</a>. In Wexelblat, Richard (ed.). <i>History of Programming Languages</i>. Academic Press. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F800025.1198417">10.1145/800025.1198417</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:42902371">42902371</a>.</cite></li>
<li><cite id="CITEREFGriswold1996" class="citation web cs1">Griswold, Ralph (2 March 1996). <a rel="nofollow" class="external text" href="https://www2.cs.arizona.edu/icon/docs/ipd266.htm">"An Overview of the Icon Programming Language; Version 9"</a>. <i>Department of Computer Science, The University of Arizona</i>.</cite></li>
<li><cite id="CITEREFTratt2010" class="citation book cs1">Tratt, Laurence (18 October 2010). <a rel="nofollow" class="external text" href="https://tratt.net/laurie/research/pubs/papers/tratt__experiences_with_an_icon_like_expression_evaluation_system.pdf">"Experiences with an icon-like expression evaluation system"</a> <span class="cs1-format">(PDF)</span>. <i>Proceedings of the 6th symposium on Dynamic languages</i>. pp.&nbsp;<span class="nowrap">73–</span>80. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F1869631.1869640">10.1145/1869631.1869640</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9781450304054</bdi>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:14588067">14588067</a>.</cite></li>
<li><cite id="CITEREFShapiro1985" class="citation magazine cs1">Shapiro, Ezra (July 1985). <a rel="nofollow" class="external text" href="https://archive.org/details/BYTE_Vol_10-07_1985-07_Computers_and_Space/BYTE%20Vol%2010-07%201985-07%20Computers%20and%20Space/page/n355">"SNOBOL and Icon"</a>. <i>Byte</i>. pp.&nbsp;<span class="nowrap">341–</span>350.</cite></li></ul>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1290876196">
/* start https://en.wikipedia.org/ */


.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .infobox .side-box{font-size:100%}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1237033735">
/* start https://en.wikipedia.org/ */


@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}


/* end https://en.wikipedia.org/ */
</style><div class="side-box side-box-right sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */


.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}


/* end https://en.wikipedia.org/ */
</style>
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist">Wikibooks has a book on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Icon_Programming" class="extiw external" title="wikibooks:Icon Programming">Icon Programming</a></b></i></div></div>
</div>
<ul><li><span class="official-website"><span class="url"><a rel="nofollow" class="external text" href="http://www.cs.arizona.edu/icon">Official website</a></span></span></li>
<li><a rel="nofollow" class="external text" href="https://github.com/gtownsend/icon">Icon</a> on <a href="GitHub" title="GitHub">GitHub</a></li>
<li><a rel="nofollow" class="external text" href="http://purl.umn.edu/107698">Oral history interview with Stephen Wampler</a>, <a href="Charles_Babbage_Institute" class="mw-redirect" title="Charles Babbage Institute">Charles Babbage Institute</a>, University of Minnesota. Wampler discusses his work on the development Icon in the late 1970s.</li>
<li><a rel="nofollow" class="external text" href="http://purl.umn.edu/107329">Oral history interview with Robert Goldberg</a>, <a href="Charles_Babbage_Institute" class="mw-redirect" title="Charles Babbage Institute">Charles Babbage Institute</a>, University of Minnesota. Goldberg discusses his interaction with Griswold when working on Icon in the classroom at <a href="Illinois_Institute_of_Technology" title="Illinois Institute of Technology">Illinois Institute of Technology</a>.</li>
<li><a rel="nofollow" class="external text" href="http://purl.umn.edu/107697">Oral history interview with Kenneth Walker</a>, <a href="Charles_Babbage_Institute" class="mw-redirect" title="Charles Babbage Institute">Charles Babbage Institute</a>, University of Minnesota. Walker describes the work environment of the Icon project, his interactions with Griswold, and his own work on an Icon compiler.</li>
<li><a rel="nofollow" class="external text" href="http://rosettacode.org/wiki/Category:Icon">The Icon Programming Language page</a> on <a href="Rosetta_Code" title="Rosetta Code">The Rosetta Code comparative programming tasks project site</a></li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox authority-control" aria-labelledby="Authority_control_databases_frameless&amp;#124;text-top&amp;#124;10px&amp;#124;alt=Edit_this_at_Wikidata&amp;#124;link=https&amp;#58;//www.wikidata.org/wiki/Q1156474#identifiers&amp;#124;class=noprint&amp;#124;Edit_this_at_Wikidata645" style="padding:3px"><table class="nowraplinks hlist mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Authority_control_databases_frameless&amp;#124;text-top&amp;#124;10px&amp;#124;alt=Edit_this_at_Wikidata&amp;#124;link=https&amp;#58;//www.wikidata.org/wiki/Q1156474#identifiers&amp;#124;class=noprint&amp;#124;Edit_this_at_Wikidata645" style="font-size:114%;margin:0 4em">Authority control databases </div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">National</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://id.loc.gov/authorities/sh85064074">United States</a></span></li><li><span class="uid"><a rel="nofollow" class="external text" href="https://www.nli.org.il/en/authorities/987007538533705171">Israel</a></span></li></ul></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://lux.collections.yale.edu/view/concept/6fe5442d-74d6-4d71-9e7d-67727f32bdba">Yale LUX</a></span></li></ul></div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-29" href="https://en.wikipedia.org/wiki/?title=Icon_(programming_language)&amp;oldid=1303143672">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>